/*
 * @Descripttion: 
 * @version: 
 * @Author: turingchang
 * @Date: 2020-12-29 09:53:15
 * @LastEditors: turingchang
 * @LastEditTime: 2020-12-29 09:56:00
 */


'use strict';
const BaseController = require('../base/base');

class TtbPushLogController extends BaseController {

    /**
     * 获取推送记录列表
     */
    async list(){
        const ctx = this.ctx;
        const query =ctx.query;
        var data = await ctx.service.push.ttbPushLog.list(query);
        data =ctx.convertToAntTableData(data);
        ctx.outSuccess(null, data);
    }

    /**
     * 推送记录详情
     */
    async info(){
        const ctx = this.ctx;
        let params ={};
        params = Object.assign(params,ctx.query);
        let res = await ctx.service.push.ttbPushLog.info(params);
        if(res.success === false){
            return ctx.outError(res.msg || '获取失败',res.data || {},res.response_code_enum || ctx.app.enums.response_code_enum.server_error);
        }
        ctx.outSuccess('成功',res.data || {});
    }

    /**
     * 添加推送记录
     */
    async add(){
        const ctx = this.ctx;
        let params = {};
        params = Object.assign(params,ctx.request.body);
        let res = await ctx.service.push.ttbPushLog.add(params);        
        if(res.success === false){
            return ctx.outError(res.msg || '添加失败',res.data || {},res.response_code_enum || ctx.app.enums.response_code_enum.server_error);
        }
        ctx.outSuccess('添加成功',res.data || {});
    }

}

module.exports = TtbPushLogController;